package com.yonyou.cyxdms.sysAuth.service.controller.manage.employee;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yonyou.cyx.framework.bean.dto.framework.RestResultResponse;
import com.yonyou.cyx.function.utils.common.StringUtils;
import com.yonyou.cyxdms.sysAuth.service.controller.WechatScanLoginController;
import com.yonyou.cyxdms.sysAuth.service.dto.CodeDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.EmployeeUpdateDTO;
import com.yonyou.cyxdms.sysAuth.service.dto.role.RolePDto;
import com.yonyou.cyxdms.sysAuth.service.service.manage.employee.EmployeeService;
import com.yonyou.cyxdms.sysAuth.service.vo.employee.*;
import com.yonyou.cyxdms.sysAuth.service.vo.weChat.WechatInfo;
import com.yonyou.cyxdms.sysAuth.service.vo.weChat.WechatLoginVO;
import com.yonyou.cyxdms.sysmanage.client.domains.dto.EmployeeDictDto;
import com.yonyou.cyxdms.sysmanage.client.vo.employee.EmployeeOrgsVO;
import com.yonyou.cyxdms.sysmanage.client.vo.employee.EmployeeVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.util.UriComponentsBuilder;

import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 经销商员工信息
 *
 * @author renwd
 * @since 2019/7/9
 */

@Api(value = "EmployeeManageController", tags = {"经销商员工信息"})
@RestController
@RequestMapping("/basedata/employees")
public class EmployeeManageController {
    @Autowired
    private EmployeeService employeeService;

    @Autowired
    private WechatScanLoginController wechatScanLoginController;


    /**
     * 销售顾问下拉数据
     *
     * @param
     * @return java.util.List<com.yonyou.cyxdms.sysAuth.service.vo.employee.ConsultantVO>
     * @author renwd
     * @since 2019/7/9
     */
    @ApiOperation(value = "销售顾问下拉数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/{menuId}/powerSalesConsultant")
    public List<ConsultantVO> qryPowerSalesConsultant() {
        return employeeService.qryPowerSalesConsultant();
    }

    /**
     * 电销顾问下拉数据
     *
     * @param
     * @return java.util.List<com.yonyou.cyxdms.sysAuth.service.vo.employee.ConsultantVO>
     * @author renwd
     * @since 2019/7/9
     */
    @ApiOperation(value = "电销顾问下拉数据")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/{menuId}/telemarkConsultant")
    public List<ConsultantVO> qryTelemarkConsultant() {
        return employeeService.qryTelemarkConsultant();
    }

    /**
     * 员工信息下拉框调用的方法
     *
     * @param queryParam
     * @return java.util.List<com.yonyou.cyxdms.sysAuth.service.vo.employee.EmployeeSelectVO>
     * @author renwd
     * @since 2019/7/9
     */
    @ApiOperation(value = "员工信息下拉框调用的方法")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/employees/dict")
    public List<EmployeeSelectVO> selectEmployees(@RequestParam Map<String, Object> queryParam) {
        return employeeService.selectEmployees(queryParam);
    }

    /**
     * 根据dealer_code查询销售顾问
     *
     * @param dealerCode
     * @return java.util.List<com.yonyou.cyxdms.sysAuth.service.vo.employee.ConsultantVO>
     * @author renwd
     * @since 2019/7/9
     */
    @ApiOperation(value = "根据dealer_code查询销售顾问")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @GetMapping("/{dealerCode}/powerDealerSalesConsultant")
    public List<ConsultantVO> qryPowerSalesConsultant(@PathVariable("dealerCode") String dealerCode) {
        return employeeService.qryPowerDealerSalesConsultant(dealerCode);
    }

    /**
     * @author ：quankk
     * @date ：2019/7/10 16:42
     * @description：
     */
    @ApiOperation(value = "根据条件查询员工信息")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @RequestMapping(method = RequestMethod.GET)
    public IPage<EmployeeSearchVO> search(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                          @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                          @RequestParam Map<String, String> param) {
        Page<EmployeeSearchVO> page = new Page<>(current, size);
        return employeeService.search(page, param);
    }

    /**
     * 根据条件查询员工信息
     *
     * @author ：李贺
     * @date ：2019/9/19
     * @description：
     */
    @ApiOperation(value = "根据条件查询员工信息")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @PostMapping("/employees")
    public IPage<EmployeeSearVO> employeeSearch(@RequestBody SearchParamVO searchParamVO) {
        Page<EmployeeSearVO> page = new Page<>(searchParamVO.getCurrentPage(), searchParamVO.getPageSize());
        return employeeService.employeeSearch(page, searchParamVO);
    }

    /**
     * 根据条件查询员工信息（提供索赔）
     *
     * @author ：谢志恺
     * @date ：2021/03/02
     * @description：
     */
    @ApiOperation(value = "根据条件查询员工信息（提供索赔）")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @PostMapping("/employeesClaim")
    public IPage<EmployeeSearClaimVO> employeeSearchClaim(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                     @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                     @RequestBody SearchParamVO searchParamVO) {
        Page<EmployeeSearClaimVO> page = new Page<>(current, size);
        return employeeService.employeeSearchClaim(page, searchParamVO);
    }

    /**
     * 厂端查询经销商员工信息
     *
     * @author ：李贺
     * @date ：2019/12/13
     * @description：
     */
    @ApiOperation(value = "厂端查询经销商员工信息")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @PostMapping("/factoryEmployeeSearch")
    public IPage<EmployeeSearVO> factoryEmployeeSearch(@ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
                                                       @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
                                                       @RequestBody SearchParamVO searchParamVO) {
        Page<EmployeeSearVO> page = new Page<>(current, size);
        return employeeService.factoryEmployeeSearch(page, searchParamVO);
    }


    /**
     * @author ：李贺
     * @date ：2019/9/18
     * @description：
     */
    @ApiOperation(value = "根据id获取tccode")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @RequestMapping(value = "/findTcCodeByType/{id}", method = RequestMethod.GET)
    public List<CodeDTO> findTcCodeByType(@PathVariable("id") Long id) {
        return employeeService.findTcCodeByType(id);
    }

    /**
     * @author ：quankk
     * @date ：2019/7/10 17:25 190823
     * @description：根据id查找员工信息
     */
    @ApiOperation(value = "根据id查找员工信息")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @RequestMapping(value = "/employee/{id}", method = RequestMethod.GET)
    public EmployeeVO findByEmployeeId(@PathVariable("id") Long id) {
        return employeeService.findByEmployeeId(id);
    }

    /**
     * @author ：quankk
     * @date ：2019/7/10 17:52
     * @description：更新员工信息
     */
    @ApiOperation(value = "更新员工信息")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    @RequestMapping(value = "/employee/{id}", method = RequestMethod.PUT)
    public ResponseEntity<EmployeeUpdateDTO> findByEmployeeId(@PathVariable("id") Long id, @RequestBody @Valid EmployeeUpdateDTO empDto,
                                                              UriComponentsBuilder uricb) {
        employeeService.updateEmpById(id, empDto);
        MultiValueMap<String, String> headers = new HttpHeaders();
        headers.set("Location", uricb.path("/basedata/employees/employee/{id}").buildAndExpand(id).toUriString());
        return new ResponseEntity<>(headers, HttpStatus.CREATED);
    }


    /**
     * 查询员工信息(员工权限编辑页面)
     *
     * @param current
     * @param size
     * @param param
     * @return
     * @author MAXINGJIAN
     * @date 2019年07月11日
     */
    @ApiOperation(value = "查询员工信息")
    @RequestMapping(value = "/permission/items", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    @ResponseBody
    public IPage<EmployeeUsersVO> searchRoleEmp(@RequestParam("pageNum") Long current, @RequestParam("limit") Long size, @RequestParam Map<String, Object> param)
    //(@RequestParam Map<String, String> param)
    {
        Page<EmployeeUsersVO> page = new Page(current, size);
        return employeeService.searchUserEmployees(page, param);
    }

    /**
     * 解锁
     *
     * @param id
     * @auther maxingjian
     * @date 2019/07/12
     */
    @ApiOperation(value = "解锁")
    @RequestMapping(value = "/removelock/{empId}", method = RequestMethod.POST)
    public void removeLockflag(@PathVariable(value = "empId") long id) {
        employeeService.removeLock(id);
    }

    /**
     * @description : 锁定
     * @author : maxingjian
     * @Date 2019/07/12
     */
    @ApiOperation(value = "锁定")
    @RequestMapping(value = "/lock/{empId}", method = RequestMethod.POST)
    public void lockflag(@PathVariable(value = "empId") long id) {
        employeeService.lock(id);

    }

    @ApiOperation(value = "废弃")
    @RequestMapping(value = "/findEmployeeRoleById/{id}", method = RequestMethod.GET)
    @ResponseBody
    public List<Map<String, Object>> findEmployeeRoleById(@PathVariable Long id) {
        List<Map<String, Object>> map = employeeService.findEmployeeRoleById(id);
        return map;
    }

    /**
     * @author ：quankk
     * @date ：2019/7/19 10:57
     * @description：新增员工信息
     */
    @RequestMapping(method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ApiOperation(value = "新增员工信息")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public ResponseEntity<EmployeeUpdateDTO> addEmployee(@RequestBody @Valid EmployeeUpdateDTO empDto, UriComponentsBuilder uricb) {
        Long id = employeeService.addEmployee(empDto);
        MultiValueMap<String, String> headers = new HttpHeaders();
        headers.set("Location", uricb.path("/basedata/employees/employee/{id}").buildAndExpand(id).toUriString());
        return new ResponseEntity<>(empDto, headers, HttpStatus.CREATED);
    }

    /**
     * @param menuId      菜单权限id
     * @param alias       别名
     * @param salesColumn 销售人员字段
     * @param orgColumn   本组织字段
     * @return
     */
    @RequestMapping(value = "/findAuthorization", method = RequestMethod.GET)
    @ApiOperation(value = "客户信息操作权限")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public String findAuthorization(@ApiParam(name = "menuId", value = "菜单id") @RequestParam(value = "menuId", defaultValue = "") Long menuId, @ApiParam(name = "alias", value = "别名") @RequestParam(value = "alias", defaultValue = "") String alias, @ApiParam(name = "salesColumn", value = "销售人员") @RequestParam(value = "salesColumn", defaultValue = "") String salesColumn, @ApiParam(name = "orgColumn", value = "组织") @RequestParam(value = "orgColumn", defaultValue = "") String orgColumn) {
        return employeeService.findAuthorization(menuId, alias, salesColumn, orgColumn);
    }

    /**
     * @param menuId      菜单权限id
     * @param alias       别名
     * @param salesColumn 销售人员字段
     * @param orgColumn   本组织字段
     * @return
     */
    @RequestMapping(value = "/findAuthorizationWithType", method = RequestMethod.GET)
    @ApiOperation(value = "客户信息操作权限")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public String findAuthorizationWithType(@ApiParam(name = "menuId", value = "菜单id") @RequestParam(value = "menuId", defaultValue = "") Long menuId,
                                            @ApiParam(name = "alias", value = "别名") @RequestParam(value = "alias", defaultValue = "") String alias,
                                            @ApiParam(name = "salesColumn", value = "销售人员") @RequestParam(value = "salesColumn", defaultValue = "") String salesColumn,
                                            @ApiParam(name = "orgColumn", value = "组织") @RequestParam(value = "orgColumn", defaultValue = "") String orgColumn,
                                            @ApiParam(name = "isDealer", value = "是否经销商") @RequestParam(value = "isDealer", defaultValue = "") boolean isDealer) {
        return employeeService.findAuthorization(menuId, alias, salesColumn, orgColumn, isDealer);
    }

    /**
     * @param menuId      菜单权限id
     * @param alias       别名
     * @param salesColumn 销售人员字段
     * @param orgColumn   本组织字段
     * @return
     */
    @RequestMapping(value = "/findAuthorizationWithType2", method = RequestMethod.GET)
    @ApiOperation(value = "客户信息操作权限")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public String findAuthorizationWithType(@ApiParam(name = "menuId", value = "菜单id") @RequestParam(value = "menuId", defaultValue = "") Long menuId,
                                            @ApiParam(name = "alias", value = "别名") @RequestParam(value = "alias", defaultValue = "") String alias,
                                            @ApiParam(name = "salesColumn", value = "销售人员") @RequestParam(value = "salesColumn", defaultValue = "") String salesColumn,
                                            @ApiParam(name = "orgColumn", value = "组织") @RequestParam(value = "orgColumn", defaultValue = "") String orgColumn,
                                            @ApiParam(name = "isDealer", value = "是否经销商") @RequestParam(value = "isDealer", defaultValue = "") boolean isDealer,
                                            @ApiParam(name = "needSaleCode", value = "是否需要销售code") @RequestParam(value = "needSaleCode", defaultValue = "") boolean needSaleCode,
                                            @ApiParam(name = "needServiceCode", value = "是否需要售后code") @RequestParam(value = "needServiceCode", defaultValue = "") boolean needServiceCode) {
        return employeeService.findAuthorization(menuId, alias, salesColumn, orgColumn, isDealer, needSaleCode, needServiceCode);
    }


    /**
     * @param menuId 菜单权限id
     * @return String
     */
    @RequestMapping(value = "/findPermissionRangeByMenu", method = RequestMethod.GET)
    @ApiOperation(value = "通过menuid获取本人本组织")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public String findPermissionRangeByMenu(@ApiParam(name = "menuId", value = "菜单id") @RequestParam(value = "menuId", defaultValue = "") Long menuId) {
        return employeeService.findPermissionRange(menuId);
    }


    /**
     * TODO description
     *
     * @param employeeId
     * @return
     * @author maxingajin
     * @date 2019年08月13日
     */
    @ApiOperation(value = "通过员工id找员工信息")
    @RequestMapping(value = "/getEmployeeById", method = RequestMethod.GET)
    public EmployeeDictDto getEmployeeById(@ApiParam(name = "employeeId", value = "员工id", required = true) @RequestParam("employeeId") Long employeeId) {
        return employeeService.getEmployeeById(employeeId);
    }

    /**
     * 查询本组织下的销售人员
     *
     * @author 李贺
     * @date 2019年09月6日
     */
    @ApiOperation(value = "查询本组织下的销售人员")
    @GetMapping("/getSalesman")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public List<EmployeeOrgsVO> getSalesman() {
        return employeeService.getSalesmans();
    }

    /**
     * 查询本菜单权限过滤销售顾问
     *
     * @author 马邢健
     * @date 2019年09月23日
     */
    @ApiOperation(value = "查询本菜单权限过滤顾问")
    @GetMapping("/getDirSalesName")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public List<EmployeeOrgsVO> getDirSalesName(@ApiParam(name = "menuId", value = "菜单id", required = true) @RequestParam(value = "menuId", required = true) Long menuId
            , @ApiParam(name = "positionCode", value = "公司id", required = true) @RequestParam(value = "positionCode", required = true) String positionCode) {
        return employeeService.getDirSalesName(menuId, positionCode);
    }

    /**
     * 新增员工
     *
     * @author 李贺
     * @date 2019年09月19日
     */
    @ApiOperation(value = "新增员工")
    @PostMapping("/employee")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public Map<String, String> createEmployee(@RequestBody EmployeeAddVO employeeAddVO) {
        return employeeService.createEmployee(employeeAddVO);
    }

    /**
     * 编辑员工回显
     *
     * @author 李贺
     * @date 2019年09月20日
     */
    @ApiOperation(value = "编辑员工回显")
    @GetMapping("/emp")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public EmployeeAddVO findEmployee(
            @ApiParam(name = "employeeNo", value = "员工id", required = true) @RequestParam("employeeNo") String employeeNo,
            @ApiParam(name = "companyId", value = "公司id") @RequestParam(value = "companyId", required = false) Long companyId) {
        return employeeService.findEmployeeByNo(employeeNo, companyId);
    }

    /**
     * 编辑员工
     *
     * @author 李贺
     * @date 2019年09月20日
     */
    @ApiOperation(value = "编辑员工")
    @PutMapping("/employee")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public Map<String, String> updateEmployee(@RequestBody EmployeeAddVO employeeInfoVO) {
        return employeeService.updateEmployee(employeeInfoVO);
    }

    /**
     * 修改权限 职位列表
     *
     * @author 李贺
     * @date 2019年09月20日
     */
    @ApiOperation(value = "修改权限 职位列表")
    @GetMapping("/position")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public IPage<PositionVO> findPosition(
            @ApiParam(name = "pageNum", value = "当前页") @RequestParam("pageNum") Long current,
            @ApiParam(name = "limit", value = "分页大小") @RequestParam("limit") Long size,
            @ApiParam(name = "employeeNo", value = "员工no", required = true) @RequestParam("employeeNo") String employeeNo) {
        Page<PositionVO> page = new Page(current, size);
        return employeeService.findPosition(page, employeeNo);
    }


    /**
     * 添加用户角色
     *
     * @author 李贺
     * @date 2019年09月20日
     */
    @ApiOperation(value = "添加用户角色")
    @PostMapping("/role")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public PositionVO addRole(@RequestBody AddRolePO addrolepo) {
        return employeeService.addRole(addrolepo);
    }

    /**
     * 获得用户可选角色列表
     *
     * @author 李贺
     * @date 2019年09月21日
     */
    @ApiOperation(value = "获得用户可选角色列表")
    @GetMapping("/role")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public List<FindRoleVO> findRole(@ApiParam(name = "employeeNo", value = "员工no", required = true) @RequestParam("employeeNo") String employeeNo,
                                     @ApiParam(name = "orgId", value = "组织Id", required = true) @RequestParam("orgId") Long orgId,
                                     @ApiParam(name = "isAdd", value = "是否是新增") @RequestParam(value = "isAdd", defaultValue = "0") Integer isAdd) {
        return employeeService.findRole(employeeNo, orgId, isAdd);
    }

    /**
     * 获得用户角色属性列表
     *
     * @return
     * @author 李贺
     * @date 2019年09月21日
     */
    @ApiOperation(value = "获得用户角色属性列表")
    @GetMapping("/role2")
    @ApiImplicitParams({@ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")})
    public Map<String, List<FindRolePositionVO>> findRole2(@ApiParam(name = "userOrgId", value = "userOrgId", required = true) @RequestParam("userOrgId") Long userOrgId) {
        return employeeService.findRole2(userOrgId);
    }

    /**
     * 保存用户权限
     *
     * @return
     * @author 李贺
     * @date 2019年09月23日
     */
    @ApiOperation(value = "保存用户权限")
    @PutMapping("/userPermission")
    public void userPermission(@ApiParam(name = "userOrgId", value = "userOrgId", required = true) @RequestBody UserPermissionPO userpermissionpo) {
        employeeService.updatePermission(userpermissionpo);
    }

    /**
     * 根据用户的userOrgId查询用户的角色Id
     *
     * @return
     * @author 李贺
     * @date 2019年09月23日
     */
    @ApiOperation(value = "根据用户的userOrgId查询用户的角色Id")
    @GetMapping("/roleId")
    public List<Long> findRoleIds(@ApiParam(name = "userOrgId", value = "userOrgId", required = true) @RequestParam Long userOrgId) {
        return employeeService.findRoleIds(userOrgId);
    }


    /**
     * 根据用户的userOrgId查询责任线索来源
     *
     * @return
     * @author 张覃
     * @date 2019年09月23日
     */
    @ApiOperation(value = "根据用户的userOrgId查询责任线索来源")
    @GetMapping("/findClueSourceids")
    public Map<String, String> findClueSourceids(@RequestParam(value = "userOrgId", required = false) Long userOrgId) {
        return employeeService.findClueSourceids(userOrgId);
    }


    /**
     * 保存用户权限
     *
     * @return
     * @author 李贺
     * @date 2019年09月24日
     */
    @ApiOperation(value = "保存用户权限")
    @PutMapping("/permission")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public void savePermission(@RequestBody RolePDto rolepdto) {
        employeeService.savePermission(rolepdto);
    }

    /**
     * 删除员工职位
     *
     * @return
     * @author 李贺
     * @date 2019年09月24日
     */
    @ApiOperation(value = "删除员工职位")
    @DeleteMapping("/userOrg")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public void deleteUserOrg(@RequestParam Long userOrgId) {
        employeeService.deleteUserOrg(userOrgId);
    }


    @ApiOperation(value = "（北新）经销商人员信息")
    @RequestMapping(value = "/getEmployee", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> getEmployee(@ApiParam(name = "请求信息", value = "请求信息", required = true) @RequestBody Map<String, Object> param) {
        String requestId = param.get("requestId").toString();
        String recordTime = param.get("recordTime").toString();
        String consumer = param.get("consumer").toString();
        String s = null;
        if (!StringUtils.isNullOrEmpty(recordTime)) {
            Long dateLong = Long.valueOf(recordTime);
            s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(dateLong));
        }
        List emplist = employeeService.getEmployee(s);
        Map<String, Object> result = new HashMap<>();
        result.put("recordTime", recordTime);
        result.put("requestId", requestId);
        result.put("list", emplist);
        return result;
    }

    /**
     * 绑定/变更手机号
     *
     * @return
     * @author 李贺
     * @date 2019年11月5日
     */
    @ApiOperation(value = "绑定/变更手机号")
    @PutMapping(value = "/updatePhone")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public void updatePhone(@RequestBody BindingPhoneVO bindingPhoneVO) {
        employeeService.updatePhone(bindingPhoneVO);
    }

    /**
     * 获得是否绑定微信信息
     *
     * @return
     * @author 李贺
     * @date 2019年11月5日
     */
    @ApiOperation(value = "获得是否绑定微信信息")
    @GetMapping(value = "/getWeChatBinding")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Map<String, String> getWeChatBinding() {
        return employeeService.getWeChatBinding();
    }

    /**
     * 绑定微信回调
     *
     * @return
     * @author 李贺
     * @date 2019年11月9日
     */
    @ApiOperation(value = "绑定微信回调")
    @PostMapping(value = "/callback")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Map<String, Object> callback(@RequestBody WechatLoginVO wechatLoginVO) {
        return wechatScanLoginController.callback(wechatLoginVO);
    }

    /**
     * 绑定/解绑微信
     *
     * @return
     * @author 李贺
     * @date 2019年11月5日
     */
    @ApiOperation(value = "获得是否绑定微信信息")
    @PutMapping(value = "/updateWeChatBinding")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "userId", name = "userId", required = true, dataType = "string", paramType = "header")
    })
    public Map<String, String> updateWeChatBinding(@RequestBody WechatInfo wechatInfo) {
        return employeeService.updateWeChatBinding(wechatInfo);
    }

    /**
     * 店铺默认接听电话配置接口
     *
     * @author zw
     * @date 2020年09月29日
     */
    @ApiOperation(value = "店铺默认接听电话配置接口")
    @GetMapping("/delaultPhoneSet")
    public RestResultResponse delaultPhoneSet(@RequestParam String dealerCode) {
        return employeeService.delaultPhoneSet(dealerCode);
    }
}
